﻿using IOP.Pulsar.Abstractions;
using IOP.Pulsar.Default;
using IOP.Pulsar.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace PulsarUnitTest
{
    public class TestStartup : IStartup
    {
        public void Configure(IServerBuilder server, IHostEnvironment env)
        {
            server.BuildPipeline<StringContext>(builder =>
            {
                builder.Use(next =>
                {
                    return async context =>
                    {
                        context.Body += "1";
                        await next(context);
                    };
                });
                builder.Use(next =>
                {
                    return async context =>
                    {
                        context.Body += "2";
                        await next(context);
                    };
                });
                builder.Use(next =>
                {
                    return async context =>
                    {
                        context.Body += "3";
                        await next(context);
                    };
                });
            });
        }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDefaultProductLineEntry();
        }
    }
}
